package com.simple.util.tag;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

import com.simple.util.common.XSSUtil;
import com.simple.util.exception.SimpleSystemException;

public class HtmlAttributeEncodeTag extends TagSupport {

    private static final long serialVersionUID = -2765597341681436542L;

    private String inputString;


    @Override
    public int doEndTag() throws JspException {
        try {
            pageContext.getOut().print(XSSUtil.htmlAttributeEncode(inputString));
        } catch (IOException e) {
            throw new SimpleSystemException("message.system.error",e);
        }
        return EVAL_BODY_INCLUDE;
    }

    @Override
    public int doStartTag() throws JspException {
        return EVAL_PAGE;
    }

    public void setInputString(final String inputString) {
        this.inputString = inputString;
    }


}
